package com.huahai.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * Knife4j接口文档配置
 */
@Configuration
@EnableSwagger2WebMvc
// 指定该配置的开发环境，使接口文档不会对外暴露！
@Profile({"test", "dev"})
public class Knife4jrConfiguration {

    @Bean
    public Docket api(){
        // 使用Swagger2语法
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("花海伙伴交友系统")
                        .description("花海伙伴交友系统接口文档")
                        .version("v4.0")
                        .build())
                .groupName("花海")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.huahai.controller"))
                .paths(PathSelectors.any())
                .build();
    }
}